require("../../assets/css/normalize.css");
require("../../assets/css/reset.css");
require("../../assets/fonts/iconfont.css");
require("./sports_course_detail.less");
// 引入模块
let dom = require("../../utils/dom.js");
let axios = require("../../utils/axios.js");

document.addEventListener("DOMContentLoaded", function () {
	// 1.左上角返回上一页
	dom.get("#back").addEventListener("click", function () {
		history.back();
	});
	//2. 获取地址栏传递的参数id
	let id = location.search.split("=").pop();

	axios.get("/api/train/courseDetail?id=" + id).then(res => {
		console.log(res);
		//将视频数据存储到localStorage中
		let data = res.data.data.fragments;
		localStorage.setItem("fragments", JSON.stringify(data));
	});
	//3.点击视频预览播放视频
	dom.get(".icon-bofang").addEventListener("click", function () {
		dom.get("video").style.display = "block";
		dom.get(".icon-bofang").style.display = "none";
		dom.get("video").play();
	});
	dom.get("video").addEventListener("ended", function () {
		dom.get(".icon-bofang").style.display = "block";
	});
});
